%% Classes and Objects

%See ExmData.m

%Create an Object of Class 'ExmData'
E1 = ExmData()

%Look at some of its properties
E1.A
E1.B

%Set its properties
E1.A=7
E1.B=9

E1.A=ones(4,1)

%Try to get/set a non-existent property
E1.C
E1.C=7


%% Add method(s) to the class and test

%If we change the class definition, we should clear objects of that class, 
%then clear the class definition before creating new objects. 

clear E1 
clear ExmData

%or, in a more heavy-handed way:

%clear
%clear classes

%Create new object
E2=ExmData()
E2.B=4

%Try our methods
E2.addAB()
E2.multAB()

E2


%% Exponential Distribution Example 1

% The distibution of intervals between events arising from a constant rate
% process. 


TSteps=100000;  %Time steps
P=.01;  %Probability of an event during time interval

%Look carefully at what this does.  '1' is and event. 
Events=double(rand(TSteps,1)<P);

%Show the events. 
figure
bar(Events)
xlabel('Time')
ylabel('Event')

%help find
ID=find(Events); %the array index of events

%The time interval between events.  Make sure you understand this. 
Intervals=ID(2:end)-ID(1:end-1);

%The distribution of interval times. 
figure
hist(Intervals,20)
xlabel('Interval Times')
ylabel('Counts')
























